The Smart ComboBox Component > Using the Smart ComboBox component

 

Using the Smart ComboBox component

Using the Smart ComboBox component is similar to using other Macromedia Flash MX components, and generally requires the following steps:

1.

Select the component from the Flash UI Component Set 4 section of the Component Panel in Flash MX

2.

Drag the component into your movie.

3.

Customize the component using the Property inspector or its ActionScript API.

The Smart ComboBox component extends the Combo Box component available with Macromedia Flash MX, and it includes all of the methods and functionality of that component. The Smart ComboBox component also adds the ability to have the user enter data directly into the component, as well as automatically save and reload the data between user sessions.

Adding additional items to the Smart Combo Box is simple. This can be accomplished by entering data directly into the Smart Combo Box component, a text field, or any other source of data.

For example, the code below only adds items to the components history if the item begins with the letter "A".

//onSubmit is a submit handler for a button component.
onSubmit = function()
{
	//get the value entered into the Smart ComboBox by the user.
	var input = eBox.getValue();
	
	//see if it begins with the letter a.
	if(input.toUpperCase().charAt(0) != "A")
	{
		//if it does not, then do nothing.
		return;
	}
	
	//it begins with a, so we add it to the history, and set it
	//to persist.
	eBox.addItem(input, input, true);
}

Once the user presses the submit button, if they entered a value that starts with the letter "A", the value will be added to the drop-down menu of the Smart Combo Box. This makes it much easier to enter the same value on a subsequent use of the form. If the component is set to persist the data, the entered values will be saved and can be used the next time the user launches the application.